package com.asialjim.wechat.official.menu;

import com.baomidou.mybatisplus.annotation.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.ibatis.type.JdbcType;
import java.io.Serializable;
import java.util.Date;
import java.util.Objects;

/**
 * <h1><em>ASIAL JIM JAVA DOC</em></h1><hr/>
 * <h2>CLASS DESCRIPTION <i>[ NAME: WeChatMenuInfo ]</i></h2><strong>
 * <p> java database object for table t_official_menu those record each official menu info
 * </strong><p><p><em>Copyright &copy; Asial Jim Co., LTD</em><hr/>
 *
 * @author Asial Jim &nbsp;&nbsp; <span>Email:<a href="mailto:asialjim@hotmail.com">asialjim@hotmail.com</a> &nbsp;&nbsp; <a href="asialjim@qq.com">asialjim@qq.com</a></span>
 * @version 1.0.0
 * @since 2021/4/5   &nbsp;&nbsp; JDK 8
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName("T_OFFICIAL_MENU")
public class OfficialMenu implements Serializable,Comparable<OfficialMenu> {
    private static final long serialVersionUID = 5445368119112294759L;

    @TableId(type = IdType.ASSIGN_UUID)
    private String id;

    private String appid;

    private Integer first;

    private Integer second;

    private String name;

    private String type;

    private String key;

    private String url;

    private String miniAppid;

    private String pagepath;

    private String mediaId;

    private Integer weight;

    @TableField(fill = FieldFill.INSERT,jdbcType = JdbcType.DATE)
    private Date createTime;

    @Override
    public int compareTo(OfficialMenu o) {
        if (Objects.isNull(second) || Objects.isNull(o.getSecond())){
            return first - o.getFirst();
        }

        int sub = first - o.getFirst();
        if (sub != 0) {return sub;}
        return second - o.getSecond();
    }
}
